home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / doom / quake.zip / HIPGRAPL.ZIP / MONSTERS.QC < prev    next >
Text File  |  1997-02-05  |  5KB  |  239 lines

  1. /* ALL MONSTERS SHOULD BE 1 0 0 IN COLOR */
  2.  
  3. // name =[framenum,    nexttime, nextthink] {code}
  4. // expands to:
  5. // name ()
  6. // {
  7. //        self.frame=framenum;
  8. //        self.nextthink = time + nexttime;
  9. //        self.think = nextthink
  10. //        <code>
  11. // };
  12.  
  13.  
  14. /*
  15. ================
  16. monster_use
  17.  
  18. Using a monster makes it angry at the current activator
  19. ================
  20. */
  21. void() monster_use =
  22. {
  23.     if (self.enemy)
  24.         return;
  25.     if (self.health <= 0)
  26.         return;
  27.     if (activator.items & IT_INVISIBILITY)
  28.         return;
  29.     if (activator.flags & FL_NOTARGET)
  30.         return;
  31.     if (activator.classname != "player")
  32.         return;
  33.  
  34. // delay reaction so if the monster is teleported, its sound is still
  35. // heard
  36.     self.enemy = activator;
  37.     self.nextthink = time + 0.1;
  38.     self.think = FoundTarget;
  39. };
  40.  
  41. /*
  42. ================
  43. monster_death_use
  44.  
  45. When a mosnter dies, it fires all of its targets with the current
  46. enemy as activator.
  47. ================
  48. */
  49. void() monster_death_use =
  50. {
  51.     local entity     ent, otemp, stemp;
  52.  
  53. // fall to ground
  54.     if (self.flags & FL_FLY)
  55.         self.flags = self.flags - FL_FLY;
  56.     if (self.flags & FL_SWIM)
  57.         self.flags = self.flags - FL_SWIM;
  58.  
  59.     if (!self.target)
  60.         return;
  61.  
  62.     activator = self.enemy;
  63.     SUB_UseTargets ();
  64. };
  65.  
  66.  
  67. //============================================================================
  68.  
  69. void() walkmonster_start_go =
  70. {
  71. local string    stemp;
  72. local entity    etemp;
  73.  
  74.    self.origin_z = self.origin_z + 1;  // raise off floor a bit
  75.     droptofloor();
  76.  
  77.     if (!walkmove(0,0))
  78.     {
  79.         dprint ("walkmonster in wall at: ");
  80.         dprint (vtos(self.origin));
  81.         dprint ("\n");
  82.     }
  83.  
  84.     self.takedamage = DAMAGE_AIM;
  85.  
  86.     self.ideal_yaw = self.angles * '0 1 0';
  87.     if (!self.yaw_speed)
  88.         self.yaw_speed = 20;
  89.     self.view_ofs = '0 0 25';
  90.     self.use = monster_use;
  91.  
  92.     self.flags = self.flags | FL_MONSTER;
  93.  
  94.     if (self.target)
  95.     {
  96.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  97.         self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
  98.         if (!self.movetarget)
  99.         {
  100.             dprint ("Monster can't find target at ");
  101.             dprint (vtos(self.origin));
  102.             dprint ("\n");
  103.         }
  104. // this used to be an objerror
  105.         if (self.movetarget.classname == "path_corner")
  106.             self.th_walk ();
  107.         else
  108.             self.pausetime = 99999999;
  109.             self.th_stand ();
  110.     }
  111.     else
  112.     {
  113.         self.pausetime = 99999999;
  114.         self.th_stand ();
  115.     }
  116.  
  117. // spread think times so they don't all happen at same time
  118.     self.nextthink = self.nextthink + random()*0.5;
  119. };
  120.  
  121.  
  122. void() walkmonster_start =
  123. {
  124. // delay drop to floor to make sure all doors have been spawned
  125. // spread think times so they don't all happen at same time
  126.     self.nextthink = self.nextthink + random()*0.5;
  127.    self.flags = self.flags | FL_MONSTER;
  128.    self.think = walkmonster_start_go;
  129.     total_monsters = total_monsters + 1;
  130. };
  131.  
  132.  
  133.  
  134. void() flymonster_start_go =
  135. {
  136.     self.takedamage = DAMAGE_AIM;
  137.  
  138.     self.ideal_yaw = self.angles * '0 1 0';
  139.     if (!self.yaw_speed)
  140.         self.yaw_speed = 10;
  141.     self.view_ofs = '0 0 25';
  142.     self.use = monster_use;
  143.  
  144.     self.flags = self.flags | FL_FLY;
  145.     self.flags = self.flags | FL_MONSTER;
  146.  
  147.     if (!walkmove(0,0))
  148.     {
  149.         dprint ("flymonster in wall at: ");
  150.         dprint (vtos(self.origin));
  151.         dprint ("\n");
  152.     }
  153.  
  154.     if (self.target)
  155.     {
  156.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  157.         if (!self.movetarget)
  158.         {
  159.             dprint ("Monster can't find target at ");
  160.             dprint (vtos(self.origin));
  161.             dprint ("\n");
  162.         }
  163. // this used to be an objerror
  164.         if (self.movetarget.classname == "path_corner")
  165.             self.th_walk ();
  166.         else
  167.             self.pausetime = 99999999;
  168.             self.th_stand ();
  169.     }
  170.     else
  171.     {
  172.         self.pausetime = 99999999;
  173.         self.th_stand ();
  174.     }
  175. };
  176.  
  177. void() flymonster_start =
  178. {
  179. // spread think times so they don't all happen at same time
  180.     self.nextthink = self.nextthink + random()*0.5;
  181.    self.flags = self.flags | FL_MONSTER;
  182.    self.think = flymonster_start_go;
  183.     total_monsters = total_monsters + 1;
  184. };
  185.  
  186.  
  187. void() swimmonster_start_go =
  188. {
  189.     if (deathmatch)
  190.     {
  191.         remove(self);
  192.         return;
  193.     }
  194.  
  195.     self.takedamage = DAMAGE_AIM;
  196. //MED
  197. //   total_monsters = total_monsters + 1;
  198.  
  199.     self.ideal_yaw = self.angles * '0 1 0';
  200.     if (!self.yaw_speed)
  201.         self.yaw_speed = 10;
  202.     self.view_ofs = '0 0 10';
  203.     self.use = monster_use;
  204.  
  205.     self.flags = self.flags | FL_SWIM;
  206.     self.flags = self.flags | FL_MONSTER;
  207.  
  208.     if (self.target)
  209.     {
  210.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  211.         if (!self.movetarget)
  212.         {
  213.             dprint ("Monster can't find target at ");
  214.             dprint (vtos(self.origin));
  215.             dprint ("\n");
  216.         }
  217. // this used to be an objerror
  218.         self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
  219.         self.th_walk ();
  220.     }
  221.     else
  222.     {
  223.         self.pausetime = 99999999;
  224.         self.th_stand ();
  225.     }
  226.  
  227. // spread think times so they don't all happen at same time
  228.     self.nextthink = self.nextthink + random()*0.5;
  229. };
  230.  
  231. void() swimmonster_start =
  232. {
  233. // spread think times so they don't all happen at same time
  234.    self.flags = self.flags | FL_MONSTER;
  235.    self.nextthink = self.nextthink + random()*0.5;
  236.     self.think = swimmonster_start_go;
  237.     total_monsters = total_monsters + 1;
  238. };
  239.